import request from "@/request";

/**
 * 获取服务器token
 * @param {Object} data
 *  account 账号
 *  password 密码
 * @param {...any} args
*/
export function getServerToken({ account, password, code, phone }) {
  return request({
    url: `/auth-server/oauth/token?grant_type=pwd&client_id=organization&client_secret=organization&username=${account}&password=${password}&scope=all&need=false&code=${code}&phone=${phone}`,
    method: "post",
    noToken: true
  });
}

/**
 * 获取用户信息
*/
export function getFullUser() {
  return request({
    url: `/store-server/medicalInstitution/loginDetail`,
    method: "get",
  });
}
/**
 * 获取路由信息
*/
export function getMenus() {
  return request({
    url: `/kernel-server/menu/getRouters`,
    method: "get",
  });
}
/**
* 获取当前用户按钮权限信息
*/
export function getMenuBtns() {
  return request({
    url: `/kernel-server/menu/getButtonPerms`,
    method: "get",
  });
}
/**
 * 用户退出
*/
export function revokeServerToken() {
  return request({
    url: `/auth-server/oauth/revoke_token`,
    method: "post",
  });
}
/**
 * 发送验证码
*/
export function getCode(phone) {
	return request({
		url: `/system-server/sms/sendCode/${phone}`,
		method: "get",
		noToken: true
	});
}
/**
 * 注册入驻
*/
export function settledRegister(data) {
	return request({
		url: `/store-server/medicalInstitution/register`,
		method: "post",
		data,
		noToken: true
	});
}
/**
 * 获取用户登录是否错误3次
*/
export function errorCount(account) {
	return request({
		url: `/store-server/settled/errorCount/${account}`,
		method: "get",
		noToken: true
	});
}
/**
 * 忘记密码
*/
export function forgot(data) {
	return request({
		url: `/store-server/medicalInstitution/forgot`,
		method: "post",
		data,
		noToken: true
	});
}
